/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rultax.core;

import org.jbox2d.common.Color3f;
import org.jbox2d.common.Vec2;
import processing.core.PApplet;
import processing.core.PVector;

/**
 *
 * @author Scott
 */
public abstract class ProcessingObject {

    private PApplet parent;
    private Physics physics;

    public ProcessingObject(PApplet parent, Physics physics) {
	this.parent = parent;
	this.physics = physics;
    }

    public PApplet getParent() {
	return parent;
    }

    public void setParent(PApplet parent) {
	this.parent = parent;
    }

    public Physics getPhysics() {
	return physics;
    }

    public void setPhysics(Physics physics) {
	this.physics = physics;
    }

    public abstract void display();

    private static final PVector v1 = new PVector();
    private static final PVector v2 = new PVector();
    public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
	parent.noStroke();
	parent.fill(0.5f * color.x, 0.5f * color.y, 0.5f * color.z, 0.5f * 255.0f);
	parent.beginShape();
	for (int i = 0; i < vertexCount; i++) {
	    v1.set(physics.coordWorldToScreen(vertices[i]));
	    parent.vertex(v1.x, v1.y);
	}
	parent.endShape(PApplet.CLOSE);
    }
}
